package com.edu.exam.enums.grading.correction;

/**
 * 操作类型枚举
 *
 * @author System
 * @version 1.0
 * @since 2025-11-15
 */
public enum CorrectionOperationType {
    /**
     * 创建
     */
    CREATE("Create", "创建"),

    /**
     * 更新
     */
    UPDATE("Update", "更新"),

    /**
     * 删除
     */
    DELETE("Delete", "删除"),

    /**
     * 审核
     */
    AUDIT("Audit", "审核"),

    /**
     * 执行
     */
    EXECUTE("Execute", "执行"),

    /**
     * 取消
     */
    CANCEL("Cancel", "取消"),

    /**
     * 撤销
     */
    REVOKE("Revoke", "撤销"),

    /**
     * 批准
     */
    APPROVE("Approve", "批准"),

    /**
     * 拒绝
     */
    REJECT("Reject", "拒绝"),

    /**
     * 提交
     */
    SUBMIT("Submit", "提交"),

    /**
     * 完成
     */
    COMPLETE("Complete", "完成"),

    /**
     * 修改分数
     */
    MODIFY_SCORE("ModifyScore", "修改分数"),

    /**
     * 状态变更
     */
    CHANGE_STATUS("ChangeStatus", "状态变更");

    private final String code;
    private final String description;

    CorrectionOperationType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取操作类型
     *
     * @param code 代码
     * @return 操作类型，找不到时返回默认值CREATE
     */
    public static CorrectionOperationType fromCode(String code) {
        for (CorrectionOperationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return CREATE;
    }
}